<!--
 * @Author: your name
 * @Date: 2022-01-19 15:54:08
 * @LastEditTime: 2022-01-19 22:19:41
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \json-serveg:\桌面2\VueStudy\vue-test4\vue-eqidemic\src\components\Citys.vue\Citys.vue
-->
<template>
  <div>
    <h3>{{cityname}}----城市的名字</h3>
     <div id="main" style="width: 100%; height: 7rem"></div>  
  </div>
</template>

<script>
import api from '../../api/index'
export default {
    name:'Citys',
    props:['cityname'],
    mounted() {
      // this.$myChart.cityMap('main',this.cityname,[])
      //获取城市接口
      api.getCity(this.cityname).then((res) => {
        // console.log('城市数据',res.data)
         let citys = res.data.retdata.subList;
          let arr = [];
          citys.forEach(element => {
            let obj = {};
            if ( element.city.endsWith("区") ||element.city.endsWith("州") ||element.city.endsWith("盟")||element.city.endsWith("旗")) {
              obj.name = element.city;
            } else {
              obj.name = element.city + "市";
            }
            obj.value = element.confirm;
            arr.push(obj);
          });
          this.$myChart.cityMap('main',this.cityname,arr)

      })
    },
}
</script>

<style>

</style>
